# coding=utf-8

# now()
# f = now
# f()
# print(f.__name__)

def log(text):
    def decorator(func):
        def wrapper(*args, **kw):
            print('%s %s():' % (text, func.__name__))
            return func(*args, **kw)

        return wrapper

    return decorator


import functools


def log1(func):
    @functools.wraps(func)
    def wrapper(*args, **kw):
        print('call %s():' % func.__name__)
        return func(*args, **kw)

    return wrapper


import functools


def log2(text):
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kw):
            print('%s %s():' % (text, func.__name__))
            return func(*args, **kw)

        return wrapper

    return decorator


@log('execute')
def now():
    print("2015-3-25")


now()


# call now():
# 2015-3-25

@log1
def now1():
    print("2015-3-11")


now1()


# call now1():
# 2015-3-11


@log2('log2')
def now2():
    """

    :rtype : object
    """
    print("2015-3-11")


now2()


# log2 now2():
# 2015-3-11


def log3(func):
    @functools.wraps(func)
    def wrapper(*args, **kw):
        print('call %s():' % func.__name__)
        return func(*args, **kw)

    return wrapper


@log3
def now3():
    print('2015-3-25')


now3()


def logger(text):
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kw):
            print('%s %s():' % (text, func.__name__))
            return func(*args, **kw)

        return wrapper

    return decorator


@logger('today')
def today():
    print('2015-3-25')


today()
print(today.__name__)
